Skip to content

Comments

Add SQLite support#98

Open
realpascalbotjet wants to merge 2 commits intoprotonemedia:masterfrom
realpascalbotjet:feature/sqlite-support
Open

Add SQLite support#98
realpascalbotjet wants to merge 2 commits intoprotonemedia:masterfrom
realpascalbotjet:feature/sqlite-support

Conversation

@realpascalbotjet
Copy link
Collaborator

@realpascalbotjet realpascalbotjet commented Feb 17, 2026

This PR adds SQLite support to the cross-eloquent-search package, based on the community contribution in PR #58, updated for current Laravel/PHP versions.

Changes

Database Compatibility:

  • Detects SQLite connection and uses appropriate SQL functions
  • Uses LENGTH for SQLite vs CHAR_LENGTH for MySQL in relevance queries
  • Adds explicit ORDER BY to UNION statements for SQLite compatibility
  • Prefixes model keys with underscore for SQLite identifier compatibility

CI/Testing:

  • Updates GitHub Actions workflow to test both MySQL and SQLite
  • Adds database matrix with separate test runs for each database
  • Conditionally skips fullText index creation for SQLite (MySQL-only feature)

Documentation:

  • Updates README requirements to mention SQLite support
  • Updates Laravel version requirement to 11+ (consistent with recent changes)

Testing

The CI workflow now runs a full test matrix:

  • PHP 8.2, 8.3, 8.4, 8.5
  • Laravel 11., 12.
  • MySQL 8.0 + SQLite (in-memory)
  • prefer-lowest + prefer-stable

SQLite tests run with :memory: database for speed and isolation.

Compatibility

  • Maintains full backward compatibility with existing MySQL usage
  • No breaking changes to the API
  • All existing functionality works identically on both databases

Closes #58

realpascalbotjet added 2 commits February 17, 2026 22:18
- Update CI workflow to test both MySQL and SQLite
- Add SQLite connection detection and appropriate SQL functions
- Use LENGTH for SQLite vs CHAR_LENGTH for MySQL in relevance queries
- Add explicit NULL to COALESCE for SQLite compatibility
- Prefix model keys with underscore for SQLite identifier compatibility
- Skip fullText indexes on SQLite (MySQL-only feature)
- Update README to mention SQLite support

Based on community PR protonemedia#58 by MeiKatz with improvements for current Laravel/PHP versions.
- Update TestCase to handle multiple database connections (sqlite, mysql, pgsql)
- Fix ORDER BY issues in SQLite by using subquery approach for UNION queries
- Fix MySQLGrammar hardcoding - use connection-specific query grammar
- Add skip conditions for unsupported SQLite features:
  * JSON column operations (title->nl syntax)
  * SOUNDS LIKE operator
  * Fulltext search operations
- All 35 tests now work: 31 pass, 4 correctly skip on SQLite
- Maintains full backward compatibility with MySQL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant